<template>
  <div>
    <router-link :to="path">
      <svg style="width: 40px;height: 40px;" t="1740234004269" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3180" width="200" height="200"><path d="M462.266 167.466l-328.098 284.381 328.098 284.359v-191.379s454.799-147.683 362.705 311.707c0 0 293.586-557.828-368.422-519.544l5.719-169.527z" fill="#2c2c2c" p-id="3181"></path></svg>
      返回
    </router-link>
    <div id="container"></div>
    <!-- <div id="mapContainer" style="width: 100vw; height: 100vh"></div> -->
  </div>
</template>
<script>
import AMapLoader from '@amap/amap-jsapi-loader';
import '@/mapJs/index.js'
export default {
  name: '',
  components: {

  },
  mixins: [],
  props: {

  },
  data() {
    return {
      path: '',
      jd: 0,
      wd: 0,
      map:null,
    }
  },
  computed: {

  },
  watch: {

  },
  mounted() {
    const { path, jd, wd } = this.$route.query;
    this.path = path;
    this.jd = jd;
    this.wd = wd;
    this.initAMap();
    // 可以的
    // window._AMapSecurityConfig = {
    //     securityJsCode: 'b7cf81192a9297f3976279b0adcab92a',
    // }
    // AMapLoader.load({
    //     key: '0856fb24f7025fd96dedbee4cdc8df38',
    //     version: '2.0',
    // })
    //     .then(AMap => {
    //         const map = new AMap.Map('mapContainer')
    //         const marker = new AMap.Marker({
    //             position: [118.611745, 24.945648], //位置
    //             centerP: [118.611745, 24.945648]
    //         })
    //         map.add(marker) //添加到地图
    //     })
    //     .catch(e => {
    //         console.error(e) //加载错误提示
    //     })

  },
  methods: {
    initAMap() {
      window._AMapSecurityConfig = {
        securityJsCode: "b7cf81192a9297f3976279b0adcab92a",
      };
      AMapLoader.load({
        key: "0856fb24f7025fd96dedbee4cdc8df38", // 申请好的Web端开发者Key，首次调用 load 时必填
        version: "2.0", // 指定要加载的 JSAPI 的版本，缺省时默认为 1.4.15
        plugins: ["AMap.Scale"], //需要使用的的插件列表，如比例尺'AMap.Scale'，支持添加多个如：['...','...']
      })
        .then((AMap) => {
          this.map = new AMap.Map("container", {
            // 设置地图容器id
            viewMode: "2D", // 是否为3D地图模式
            zoom: 16, // 初始化地图级别
            // center: [118.611745, 24.945648], // 初始化地图中心点位置
            center: [this.jd, this.wd], // 初始化地图中心点位置
          });
          const marker = new AMap.Marker({
            // position: [118.611745, 24.945648], //位置
            position: [this.jd, this.wd], //位置
          })
          this.map.add(marker)
        })
        .catch((e) => {
          console.log(e);
        });
    }
  },
  destroyed() {
    this.map.destroy();
    this.map = null;
  }
};
</script>
<style scoped>
#container {
  padding: 0px;
  margin: 0px;
  width: 100%;
  height: 800px;
}
a{
  text-decoration:  none;
}
</style>